package com.crawler.http

import akka.actor.{ActorSystem, PoisonPill, Props}
import akka.cluster.singleton.{ClusterSingletonManager, ClusterSingletonManagerSettings}
import akka.http.scaladsl.Http
import com.crawler.crane.CraneTest
import com.crawler.proxy.ProxyUtils
import com.crawler.store.Consumer
import com.typesafe.config.ConfigFactory
import com.crawler.actor.RouterActor

import scala.util.{Failure, Success}

/**
  * Created by tongtao.zhu on 2016/11/23.
  */
object Main{

  def main(args: Array[String]) {
    new CraneTest().run()
//      Master startServer(5000)
  }
}

object Master extends ApiRoutes{
  def startServer(port: Int): Unit ={
    val api = routes
    val bindingFuture = Http().bindAndHandle(handler = api, interface =host, port = port) map { binding =>
      println(s"REST interface bound to ${binding.localAddress}") } recover { case ex =>
      println(s"REST interface could not bind to $host:$port", ex.getMessage)
    }
    bindingFuture.onComplete {
      case Success(binding) =>
        println(binding)
      case Failure(e) =>
        println(e)
    }
  }
}
